<?php
defined( '_VALID_MOS' ) or die('<script>window.location.href="http://www.kinifurniture.com";</script>');


if(!$page_no)
	$page_no=1;
$MAX=$Small_box_end;
$MAX=9;
$lastrow=$MAX+$page_no;
if(!next_page)
	$next_page=1;
$next_page=$next_page+1;

$imgSr=$page_no;

	if($changesort)
	{
		echo '<script>window.location.href="http://www.kinifurniture.com/index.php?show=collection&sort=wood&sortwood='.$sortwood.'";</script>';
	}
if(!$sort)
$sort='all';

if($sort=='indoor')
{
	$condition=" where indoor='Y'";
	$judulsort="Sort by Indoor";
	$typewood='';
}
if($sort=='outdoor')
{
	$condition=" where outdoor='Y'";
	$judulsort="Sort by Outdoor";
	$typewood='';
}
if($sort=='wood')
{
	if($sortwood)
	{
		$condition=" where typeofwood='$sortwood'";
		if ($sortwood=='EOW') $selected1='selected';
		if ($sortwood=='RTW') $selected2='selected';
		if ($sortwood=='VTW') $selected3='selected';
	}
	else
		$condition="";
	$judulsort="Sort by Teakwood";
	$typewood='	
	<form name="sortlist" action="" method="post">
<select name="sortwood" onchange="document.sortlist.submit();">
				<option value="NONE" '.$selected0.'>please select ...</option>
                 <option value="EOW" '.$selected1.'>European Oak Wood</option>
                 <option value="RTW" '.$selected2.'>Reclaimed Teak Wood</option>
                 <option value="VTW" '.$selected3.'>Village Teak Wood</option>
                </select>
				<input name="changesort" type="hidden" value="changesort" />
				</form>
';
}
if($sort=='all')
{
	$condition="";
	$judulsort="Sort all Collection";
	$typewood='';
}

if ($sort=='wood' and (!$sortwood or $sortwood=='NONE'))
{$all_item_list='<br/><table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
  <td align="center"><a href="index.php?show=collection&sort=wood&sortwood=EOW"><img border="0" src="assets/collection/EOW.jpg" /></a></td>
  <td align="center"><a href="index.php?show=collection&sort=wood&sortwood=RTW"><img border="0" src="assets/collection/RTW.jpg" /></a></td>
  <td align="center"><a href="index.php?show=collection&sort=wood&sortwood=VTW"><img border="0" src="assets/collection/VTW.jpg" /></a></td>
  </tr><table>';
	$typewood='';
} else {
$qry="select * from koleksi ".$condition."order by nama asc";
	$lim_min = ($page_no-1)*$MAX;
 
	$Qry="$qry limit $lim_min,$MAX"; 
	$sqlResult=$dbh->query($Qry);
		
	$total_row=$dbh->query($qry);
	$TOTAL_RECORDSET=mysql_num_rows($total_row);
		
$all_item_list='<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr><td>
	<table width="100%" border="0" cellspacing="3" cellpadding="0">
  <tr>';
  
  $i=0;	
 if($TOTAL_RECORDSET>0)
  { 	
while($sqlRow=@mysql_fetch_object($sqlResult))
{
$noid=$sqlRow->id;
$image=$sqlRow->image;
if ($image=='') $image='noimg.png';
$nama=$sqlRow->nama;	
		
if($i%3==0)
	{
       $all_item_list.='</tr>
</table>
</td>
  </tr>
  <tr><td height="5"></td></tr>
  <tr><td>
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>';

	}
		
$all_item_list.='<td>&nbsp;</td><td width="172">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
    <td align="center"><a href="index.php?show=product&coll='.$noid.'"><img border="0" src="assets/collection/'.$image.'" /></td>
  </tr>
    <tr>
    <td align="center">'.$nama.'</td>
  </tr>
</table>
</td>
<td>&nbsp;</td>';
	
$i++;
		}
		
}
else
{
 $all_item_list.='<td align="center" class="headning_empty ">NO RECORD </td>';
}
	
	$all_item_list.='</tr>
</table>
</td>
  </tr></tr></table>';

//=====================Starting Pagination From Here==========================
	
	//global $my_page_name;
	$my_page_name="./index.php?show=collection&sort=".$sort;
	if ($sort=='wood') $my_page_name.="&sortwood=".$sortwood;
	include("pagination.inc");

//=====================Ending Pagination Here==========================	
}
?>